package com.zlzxm.shoesmarket.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.util.ZViewHelp;
import com.zlzxm.shoesmarket.view.adapter.ADMarkets;
import com.zlzxm.shoesmarket.view.adapter.entity.EntityMarket;

import java.util.List;

/**
 * CREATE BY zlzxm ON 4/13/21
 */
public class MarketView extends LinearLayout {


    private RecyclerView rvMarkets;

    private ADMarkets adMarkets = new ADMarkets(null);


    public MarketView(Context context) {
        this(context,null);
    }

    public MarketView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public MarketView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        initView();
    }



    private void initView(){

        LayoutInflater.from(getContext()).inflate(R.layout.layout_markets,this,true);

        rvMarkets  = ZViewHelp.findById(this,R.id.rvMarkets);
        rvMarkets.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.HORIZONTAL,false));
        rvMarkets.setAdapter(adMarkets);

    }

    public void updateMarkets(List<EntityMarket> markets){

        adMarkets.setList(markets);

    }


}
